<!--
 * @Author: cgl
 * @Date: 2023-06-19 10:06:51
 * @LastEditors: cgl
 * @LastEditTime: 2023-09-19 10:01:23
 * @FilePath: \public-health-emergencies-fed:\新放射\新radiation-hygiene-fe\src\views\slide\components\index.vue
 * @Description:
 *
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved.
-->
<template>
  <div class="container">
    <div v-if="activeNameEquipment == 0">
      <basicInfo
        @loadingchange="emitloadingchange"
        :inspectionList="inspectionList"
        :basicForm="basicForm"
        :lrstatus="lrstatus"
        :activeNameEquipment="activeNameEquipment"
      ></basicInfo>
    </div>
    <div v-else-if="activeNameEquipment == -1">
      <basicInfo
        @loadingchange="emitloadingchange"
        :inspectionList="inspectionList"
        :basicForm="basicForm.appendDetectionVo"
        :lrstatus="lrstatus"
        :activeNameEquipment="activeNameEquipment"
      ></basicInfo>
    </div>
    <div v-else-if="activeNameEquipment == 'index'">
      <basicInfo
        @loadingchange="emitloadingchange"
        :basicForm="basicForm.protectionDetectionVo"
        :lrstatus="lrstatus"
        :activeNameEquipment="activeNameEquipment"
      ></basicInfo>
    </div>
    <div v-else-if="activeNameEquipment == 'envir'">
      <basicInfo
        @loadingchange="emitloadingchange"
        :basicForm="basicForm.environmentDetectionVo"
        :lrstatus="lrstatus"
        :activeNameEquipment="activeNameEquipment"
      ></basicInfo>
    </div>
    <div v-else-if="activeNameEquipment == 'cbct'">
      <basicInfo
        @loadingchange="emitloadingchange"
        :basicForm="basicForm.cbctDetectionVo"
        :lrstatus="lrstatus"
        :activeNameEquipment="activeNameEquipment"
      ></basicInfo>
    </div>
    <div v-else>
      <div v-if="comp">
        <component
          :is="comp"
          :tabList="tabList"
          :activeNameEquipment="activeNameEquipment"
          @loadingchange="emitloadingchange"
          :basicForm="basicForm"
        ></component>
      </div>
      <div v-else-if="appendComp">
        <component
          :is="appendComp"
          @loadingchange="emitloadingchange"
          :basicForm="basicForm.appendDetectionVo"
        ></component>
      </div>
    </div>
  </div>
</template>

<script>
import basicInfo from './basicInfo'

export default {
  name: 'Index',
  components: {
    basicInfo,
  },
  props: {
    //
    tabList: {
      type: Array,
      default: () => ([])
    },
    // tab栏
    activeNameEquipment: {
      type: String,
      default: '0'
    },
    // 基本信息数据
    basicForm: {
      type: Object,
      default: () => ({})
    },
    // 状态
    lrstatus: {
      type: String,
      default: ''
    },
    // 检测类型
    inspectionList: {
      type: Array,
      default: () => ([])
    },
  },
  data() {
    return {
      importFlag: false,
      comp: null,
      appendComp: null,
      notAutoArr: [0, -1, 'index', 'envir', 'cbct'],
    }
  },
  watch: {
    activeNameEquipment: {
      handler(value) {
        let appendValue = ''
        if (this.notAutoArr.indexOf(value) === -1) {
          if (value.indexOf('append-') === -1) {
            let code = value
            if (value.indexOf(':') > -1) {
              code = value.split(':')[1]
            }
            this.comp = (resolve) =>
              require.ensure([], () =>
                resolve(
                  require(`@/views/slide/components/testItem/testItem${code}.vue`)
                )
              )
            this.appendComp = null
          } else {
            appendValue = value.replace('append-', '')
            this.appendComp = (resolve) =>
              require.ensure([], () =>
                resolve(
                  require(`@/views/slide/components/testItem/testItem${appendValue}.vue`)
                )
              )
            this.comp = null
          }
        }
      },
    },
  },
  methods: {
    emitloadingchange(val) {
      this.$emit('loadingchange', val)
    },
  },
  updated() {
    this.$nextTick(() => {
      window.MathJax.Hub.Typeset()
    })
  },
}
</script>

<style lang="scss" scoped>
@import "./content.scss";
</style>
